package br.unesp.demac.ccn2007.aula6.ex1_EscritaBytes;

import java.io.*;

public class CopiaBytes {

	/**
	 * @param args
	 */
	
	public static void copiaArquivo(String origem, String destino){
		try {
			BufferedInputStream org = new BufferedInputStream(new FileInputStream(origem));
			BufferedOutputStream dest = new BufferedOutputStream(new FileOutputStream(destino));
			
			int disp;
			try {
				disp = org.available();
				byte dados[] = new byte[disp];
				org.read(dados, 0, disp);
				dest.write(dados, 0, disp);
				
				System.out.println(disp + " bytes copiados.");
				org.close();
				dest.flush();
				dest.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		copiaArquivo("C://workspace//LCP//exercicios//src//br//unesp//demac//ccn2007//aula6//test.txt","C://workspace//LCP//exercicios//src//br//unesp//demac//ccn2007//aula6//test_2.txt");
	}

}
